<?php

class obj
{

}

$obj = new obj();
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
//$redis->select(2);
//$redis->set('obj',serialize($obj),10);
//var_dump(unserialize($redis->get('obj')));
//echo "ok";
//$redis->mset(['k1'=>'v1','k2'=>'v2']);
//var_dump($redis->mget(['k1','k2']));
//var_dump($redis->msetnx(['k3'=>'aaa']));
//$redis->set('num',1);
// var_dump($redis->incrBy('num',10));
// var_dump($redis->get('num'));
if ($redis->exists('num')) {

//    var_dump($redis->append('num',5));
    $redis->setRange('num', 0, 'qqqqqqqqqqqqqqqqqqqqqqqqqqq');
//        var_dump($redis->get('num'));
}

//var_dump($redis->substr('num',1,2));
//var_dump($redis->getRange('num',1,2));
//var_dump($redis->strlen('num'));
//var_dump($redis->getSet('k1ee','new'));
//var_dump($redis->bitCount('bits'));
//var_dump($redis->setBit('bit',1,1));
//var_dump($redis->getBit('bit',1));
//var_dump($redis->strlen('bit'));
//var_dump($redis->bitCount('bits'));
//var_dump($redis->setBit('bits',0,1));
//var_dump($redis->setBit('bits',1,1));
//var_dump($redis->setBit('bits-1',0,1));
//var_dump($redis->setBit('bits-1',3,1));
//var_dump($redis->setBit('bits',100,1));
//var_dump($redis->getBit('bits',4));
//var_dump($redis->bitCount('bits'));
//var_dump($redis->delete('bits-1'));
//var_dump($redis->strlen('bits-1'));
//var_dump($redis->bitOp('and','and-result','bits-1',''));
//var_dump($redis->set('bit1', '1')); // 11 0001
//var_dump($redis->set('bit2', '222')); // 11 0010
//var_dump($redis->set('bit3', '2223222')); // 11 0010
//
//var_dump($redis->bitOp('AND', 'bit', 'bit1', 'bit2','bit3')); // bit = 110000
//var_dump($redis->bitOp('OR', 'bit', 'bit1', 'bit2')); // bit = 110011
//var_dump($redis->bitOp('NOT', 'bit', 'bit1', 'bit2','bit3')); // bit = 110011
//var_dump($redis->bitOp('XOR', 'bit', 'bit1', 'bit2')); // bit = 11
//var_dump($redis->getBit('bit',0));
//var_dump($redis->keys('bit*'));
//var_dump($redis->del('l'));
//var_dump($redis->lPush('l', 'v1', 'v2', 'v3', 'v4'));
//var_dump($redis->lRange('l',0,-1));
//var_dump($redis->msetnx(['bit12'=>1111]));//key 不存在的时候才设置
//var_dump($redis->setex('bits',10,'毫秒'));
//var_dump($redis->ttl('ttl'));
//var_dump($redis->dump('bits'));
//var_dump($redis->set('bits-1','val'));
//var_dump($redis->expire('l',10));
//var_dump($redis->expireAt('bits-1',1531662241));
//var_dump($redis->ttl('bits-1'));
//var_dump($redis->keys('*'));
//var_dump($redis->restore())

//var_dump($redis->migrate());
//var_dump($redis->keys('*'));
//var_dump($redis->select(0));
//var_dump($redis->set('game','cod'));
//var_dump($redis->set('game','cod'));
//var_dump($redis->move('key',1));
//var_dump($redis->get('key'));
//var_dump($redis->flushAll());
//var_dump($redis->select(1));
//var_dump($redis->get('key'));
//var_dump($redis->object('refcount','game'));
//var_dump($redis->object('encoding','game'));
//var_dump($redis->object('idletime','game'));
//var_dump($redis->get('game'));
//var_dump($redis->object('idletime','game'));
//var_dump($redis->object('encoding','game'));
//var_dump($redis->set('age',26));
//var_dump($redis->object('encoding','age'));
//var_dump($redis->set('phone',15820123123));
//var_dump($redis->object('encoding','phone'));

//var_dump($redis->set('key','rte'));
//var_dump($redis->expire('key',10));
//var_dump($redis->ttl('key'));
//var_dump($redis->persist('key'));
//var_dump($redis->ttl('key'));
//var_dump($redis->randomKey());
//var_dump($redis->rename('key','newkey'));
//$redis->set('key1', 'val1');
//$redis->set('key2', 'val2');
//var_dump($redis->renameNx('key1', 'key2'));
//var_dump($redis->dump('key1'));
//var_dump($redis->get('key1'));
//var_dump($redis->get('key2'));
//var_dump($redis->restore());

//var_dump($redis->lPush('list', 1, 3,  5, 2,8));
//var_dump($redis->sort('list',['limit'=>[0,5],'sort'=>'desc']));
//$redis->lPush('uid',1);
//$redis->set('name_1','admin1');
//$redis->set('level_1',10);
//$redis->lPush('uid',2);
//$redis->set('name_2','admin2');
//$redis->set('level_2',20);
//$redis->lPush('uid',3);
//$redis->set('name_3','admin3');
//$redis->set('level_3',30);
//var_dump($redis->sort('uid',['by'=>'level_*','get'=>['level_*','name_*']]));
//foreach ($redis->sort('uid') as $item) {
//    var_dump($redis->get('name_'.$item));
//}
//var_dump($redis->flushAll());
//var_dump($redis->hMset('user_info_1', ['name' => 'Tom', 'level' => 10]));
//var_dump($redis->hMset('user_info_2', ['name' => 'Jack', 'level' => 20]));
//var_dump($redis->hMset('user_info_3', ['name' => 'Lear', 'level' => 30]));
//var_dump($redis->sort('uid',['by'=>'user_info_*->level','get'=>['user_info_*->name'],'store'=>'sort_res']));
//var_dump($redis->lRange('sort_res',0,-1));
//var_dump($redis->pexpire('sort_res',200));
//var_dump($redis->keys('*'));
//var_dump($redis->set('set','adsa'));
//var_dump($redis->type('set'));
//$iterator =null;
//while($keys=$redis->scan($iterator)){
////    var_dump($keys);
//    foreach ($keys as $index => $key) {
//        echo $key.PHP_EOL;
//    }
//}
//var_dump($redis->sAdd('arr','val_1','val_2','val_3','val_4','val_5','val_6'));
//var_dump($redis->sMembers('arr'));
//var_dump($redis->sCard('arr'));
//var_dump($redis->sAddArray('arr2',['val_1','val2','val7']));
//var_dump($redis->sAddArray('arr3', ['val_1', 'val2', 'val8']));
//var_dump($redis->sAddArray('arr4',['val_1','val2','val9']));
//var_dump($redis->sMembers('arr2'));
//var_dump($redis->sDiff('arr','arr2','arr3','arr4'));
//var_dump($redis->sDiffStore('dstKey','arr','arr2','arr3','arr4'));
//var_dump($redis->sMembers('dstKey'));
//var_dump($redis->sMembers('arr3'));
//var_dump($redis->sIsMember('dstKey','val_222'));
//var_dump($redis->sMove('dstKey', 'arr3', 'val_5'));
//var_dump($redis->sPop('arr3'));
//var_dump($redis->sMembers('arr3'));
//var_dump($redis->sRandMember('arr3',2));
//var_dump($redis->sRem('arr3','val2'));
//var_dump($redis->sMembers('arr3'));

//var_dump($redis->sUnion('arr3','dstKey'));


//hash
//var_dump($redis->keys('*'));
//var_dump($redis->hSet('key','name','yfl'));
////var_dump($redis->hSet('key','name','jzm'));
//var_dump($redis->hMset('key',['name'=>'yfl','age'=>20]));
//var_dump($redis->hGet('key','name'));
//var_dump($redis->hMGet('key',['name','age']));
//var_dump($redis->hDel('key','age'));
//var_dump($redis->hGetAll('key'));
//var_dump($redis->hMset('k2',['name'=>'jzm','age'=>23]));
//var_dump($redis->hGetAll('k2'));
//var_dump($redis->hExists('k2','name2'));
//var_dump($redis->hIncrBy('k2','age',-100));
//var_dump($redis->hGetAll('k2'));

//var_dump($redis->hKeys('k2'));
//var_dump($redis->hLen('k2'));
//var_dump($redis->hVals('k2'));
//list
//var_dump($redis->lPush('list', 'v1', 'v2', 'v3', 'v4'));
//var_dump($redis->lRange('list',0,10));
//var_dump($redis->lRem('list','v4',0));
//var_dump($redis->lRange('list',0,10));
//var_dump($redis->lSet('list',0,'v33'));

//var_dump($redis->lPush('list', 1, 2, 3, 4));
//var_dump($redis->rPush('list2', 1, 2, 3, 4));
//var_dump($redis->lRange('list', 0, 3));
//var_dump($redis->lRange('list2', 0, 3));
//var_dump($redis->rpoplpush());
//var_dump($redis->)

//sortSet
//var_dump($redis->zAdd('z', 1, 'v1', 2, 'v2', 3, 'v3', 4, 'v4'));
//var_dump($redis->zCount('z',2,3));
//var_export($redis->zRange('z',0,-1,true));
//var_dump($redis->zCard('z'));
//var_dump($redis->zIncrBy('z',100,'v1'));
//var_export($redis->zRevRange('z',0,-1,true));
//var_dump($redis->zRangeByScore('z','0','4',['withscores'=>true]));

//var_dump($redis->zUnion())
//var_dump($redis->flushAll());
var_dump($redis->keys('*'));
//var_dump($redis->eval("return redis.call('set','foo','bar')"));
//var_dump($redis->get('foo'));
var_dump($redis->eval("return redis.call('set',KEYS[1],'bar')"));



